<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class Controller extends CController{
	private $_pageTitle;

	/**
	 * @return string the page title. Defaults to the controller name and the action name.
	 */
	public function getPageTitle()
	{
		if($this->_pageTitle!==null)
			return $this->_pageTitle;
		else{
			$cName=ucfirst(basename($this->getId()));
			if($this->getAction()!==null && strcasecmp($this->getAction()->getId(),$this->defaultAction)){
				$aName=ucfirst($this->getAction()->getId().' '.$cName);
				return Yii::t('back', $aName) . $this->getPageTitlePostfix();
			}else{
				$cName=StringHelpers::pluralize($cName);
				return Yii::t('back', $cName) . $this->getPageTitlePostfix();
			}
		}
	}

	/**
	 * @param string $value the page title.
	 */
	public function setPageTitle($value)
	{
		$this->_pageTitle=$value;
	}
	
	public function getPageTitlePostfix(){
		return ' | ' . Yii::app()->name;
	}
}